<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        var da=new Date();
        console.log(da);
        console.log(da.getTime());
        console.log(da.getYear());
        console.log(da.getFullYear());//年
        console.log(da.getMonth());//月
        console.log(da.getDate());//日
        console.log(da.getHours());//时
        console.log(da.getMinutes());//分
        console.log(da.getSeconds());//秒
        console.log(da.toLocaleString());
        console.log(da.toLocaleDateString());
        console.log(da.toLocaleTimeString());
        console.log("============");
        da=new Date(Date.parse("1/3/2010"));
        da=new Date("1/3/2010");

        function dateToStr(datetime){
            var year = datetime.getFullYear();
            var month = datetime.getMonth()+1;//js从0开始取
            var date = datetime.getDate();
            var hour = datetime.getHours();
            var minutes = datetime.getMinutes();
            var second = datetime.getSeconds();

            if(month<10){
                month = "0" + month;
            }
            if(date<10){
                date = "0" + date;
            }
            if(hour <10){
                hour = "0" + hour;
            }
            if(minutes <10){
                minutes = "0" + minutes;
            }
            if(second <10){
                second = "0" + second ;
            }
            var time = year+"-"+month+"-"+date+" "+hour+":"+minutes+":"+second; //2009-06-12 17:18:05
// alert(time);
            return time;
        }
        da=new Date();
        console.log(dateToStr(da));

        console.log("=================");
        var re=new RegExp();
        re=new RegExp("dsssss");
        re=new RegExp(/dssssss/);
        console.log(re);
        re.compile("das");//设置表达式
        console.log(re);
        console.log(re.exec("dasdddddaas"));//返回匹配的值
        console.log(re.test("das"));//判断是否符合正则表达式

        var str="dsasdads";
        console.log(str.search(/da/));//4
        console.log(str.match(/ds/))
        console.log(str.replace(/ds/,"aaa"));//只会替换第一个
        console.log(str.split(/s/));//分割成数组

    </script>
</head>
<body>

</body>
</html>